package com.miyake.dsp.filter;

import com.miyake.dsp.filter.FilterSetting.FilterAlgo;
import com.miyake.dsp.filter.FilterSetting.FilterType;
import com.miyake.dsp.filter.FilterSetting.WindowType;

public class ScilabCommand {
	public String getApprox(FilterAlgo filterAlgo) {
		switch (filterAlgo) {
		case Butterworth:
			return "'butt'";
		case Chebyshev1:
			return "'cheb1'";
		case Chebyshev2:
			return "'cheb2'";
		case Elliptic:
			return "'ellip'";
		}
		return null;
	}
	
	public String getDelta(double delta, double delta2) {
		return  "[" + String.format("%.3f", delta) + 
		" " + String.format("%.3f", delta2) + "]";
	}
	
	public String getCutoff(double cutoff, double cutoff2, double samplingFrequency) {
		return  "[" + String.format("%.3f", cutoff/samplingFrequency) + 
			" " + String.format("%.3f", cutoff2/samplingFrequency) + "]";
	}
	
	public String getOrder(int order) {
		return String.valueOf(order);
	}
	
	public String getFilterType(FilterType type) {
		switch (type) {
		case Lowpass:
			return "'lp'";
		case Highpass:
			return "'hp'";
		case Bandpass:
			return "'bp'";
		case Stopband:
			return "'sb'";
		}

		return null;
	}
	
	public String getWindowType(WindowType wtype) {
		if (wtype.equals(WindowType.Rectangle)) {
			return "'re'";
		}
		else if (wtype.equals(WindowType.Triangle)) {
			return "'tr'";
		}
		else if (wtype.equals(WindowType.Hamming)) {
			return "'hm'";
		}
		else if (wtype.equals(WindowType.Hanning)) {
			return "''hn";
		}
		else if (wtype.equals(WindowType.Kaiser)) {
			return "'kr'";
		}

		return null;
		
	}
}
